#include<stdio.h>
#include<string.h>
#include<unistd.h>



int main()
{
    FILE* fp = fopen("log.txt","w");
    if(fp == NULL)
    {
        perror("fopen");
        return 1;
    }

    char buffer[1024];
    const char* message = "hello";
    int i = 0;
    while(i<10)
    {
        snprintf(buffer,sizeof(buffer),"%s:%d\n",message,i);
        fputs(buffer,fp);
        i++;
    }
    fclose(fp);
    
    return 0;
}
